﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BingVis.SilverlightClient.Common;

namespace BingVis.SilverlightClient.GoogleTransit
{
    public class CompressedFareTap
    {
        public string StopName { get; private set; }
        public decimal Amount { get; private set; }
        public DateTime Time { get; private set; }

        public CompressedFareTap(string name,decimal amt, DateTime time)
        {
            StopName = name;
            Amount = amt;
            Time = time;
        }
    }

    public class CompressedFareTapLoader : TransitLoaderBase<CompressedFareTap>
    {
        public CompressedFareTapLoader(IGTFSFile file)  
            : base(file)
        {
            _parser = new CSVParser("", false);
        }

        public override void ProcessItem(ICSVLine line)
        {
            var stopName = line[0];            
            foreach (var cft in line.Values.Skip(1))
            {
                var vals = cft.Split("|".ToCharArray());                
                var result = new CompressedFareTap(
                                                stopName, 
                                                decimal.Parse(vals[1]), 
                                                DateTime.Parse(vals[0]));

                Items.Add(result);
                OnItemLoaded(result);
            }            
        }
    }
}
